import { createRouter, createWebHistory } from 'vue-router'

const router = createRouter({
    history: createWebHistory(),
    routes: [
        {
            path: '/login',
            component: () => import('../pages/login.vue')
        },
        {
            path: '/',
            redirect: '/login'
        },
        {
            path: '/register',
            component: () => import('../pages/register.vue')
        },
        {
            path: '/index',
            component: () => import('../pages/index.vue'),
            children:[
                {
                    path: 'main',
                    name: 'main',
                    component: () => import('../components/main.vue')
                },
                {
                    path:'/index',
                    redirect: '/index/main'
                },
                {
                    path: 'cart',
                    name: 'cart',
                    component: () => import('../components/cart.vue')
                },
                {
                    path: 'detail/:id',
                    component: () => import('../components/detail.vue')
                }
            ]
        }
    ]
})

export default router